package org.dxy.types.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description: 设备状态
 *
 * @author: Administrator
 * @createTime: 2025/5/5 16:20
 */
@Getter
@AllArgsConstructor
public enum EquipmentStatusEnum {

    REGISTERED("registered", "设备已注册，未激活"),

    ACTIVATED("activated", "设备已激活，正常可用"),

    IDLE("idle", "设备空闲，等待任务"),

    WORKING("working", "设备工作中，执行任务"),

    STOPPED("stopped", "设备任务停止，待恢复"),

    FAULT("fault", "设备故障，待维修"),

    MAINTENANCE("maintenance", "设备维护中，暂停使用"),

    DEACTIVATED("deactivated", "设备已停用，暂不可用"),

    RETIRED("retired", "设备已退役"),;

    private final String key;         // 用于标识状态的代码（小写）
    private final String description; // 状态的描述


    /**
     * 是否可分配任务。
     */
    public boolean isDispatchable() {
        return this == ACTIVATED || this == IDLE;
    }

    /**
     * 是否可用（不包括停用和故障）。
     */
    public boolean isAvailable() {
        return this == ACTIVATED || this == IDLE || this == WORKING;
    }

}